/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.lacibMusic.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author AlanmLira
 */
@Entity
@Table(name = "GeneroMusical")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "GeneroMusical.findAll", query = "SELECT g FROM GeneroMusical g order by g.nomeGeneroMusical"),
    @NamedQuery(name = "GeneroMusical.findById", query = "SELECT g FROM GeneroMusical g WHERE g.id = :id"),
    @NamedQuery(name = "GeneroMusical.findByNomeGeneroMusical", query = "SELECT g FROM GeneroMusical g WHERE g.nomeGeneroMusical = :nomeGeneroMusical")})
public class GeneroMusical implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Size(max = 45)
    @Column(name = "nomeGeneroMusical")
    private String nomeGeneroMusical;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "estiloMusicalid")
    private List<Musica> musicaList;

    public GeneroMusical() {
    }

    public GeneroMusical(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNomeGeneroMusical() {
        return nomeGeneroMusical;
    }

    public void setNomeGeneroMusical(String nomeGeneroMusical) {
        this.nomeGeneroMusical = nomeGeneroMusical;
    }

    @XmlTransient
    public List<Musica> getMusicaList() {
        return musicaList;
    }

    public void setMusicaList(List<Musica> musicaList) {
        this.musicaList = musicaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GeneroMusical)) {
            return false;
        }
        GeneroMusical other = (GeneroMusical) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.lacibMusic.entidades.GeneroMusical[ id=" + id + " ]";
    }
    
}
